<meta charset="utf-8">
<?php
	require('connect_sql.php');	

	if(get_magic_quotes_gpc()){
		foreach ($_POST as $key => $value) {
			$_POST[$key]=addslashes($value);
		}
	}


		if($_POST['userid']&&$_POST['username']&&$_POST['classid'])
		{
			if($_POST['classid']>0&&$_POST['classid']<7)
			{
				mysql_query('set names utf8');
				$phone=$_POST['phone'];

				$query="insert into userapply (userid,email,phone,username,classid) values 
		 		('".$_POST['userid']."','".$_POST['email']."','".$phone."','".$_POST['username']."','".$_POST['classid']."');";
		 		$result=mysql_query($query)or die("注册失败：".mysql_error()."<br>提示：该用户名已注册或服务器出错。");
		 		logs();
			}
			else
			{
				?>
				<script type="text/javascript">
				alert("请按规则输入部门哦！");
				windowlocation=history.back();
				</script>
				<?php
			}
		 

		}	
		else
		{
			?>
			<script type="text/javascript">
			alert("请输入必要信息！");
			windowlocation=history.back();
			</script>
			<?php
		} 



	function logs(){
	 	?>
	 	<script language="javascript" type="text/javascript">
	 	alert("注册成功，请等待审核。");
	 	window.location.href="../index.php";
	 	</script>
	 	<?php
	 	
	 }
?>